package com.ruoyi.web.controller.analysiswarning;

import com.ruoyi.analysiswarning.domain.AnalyOverview;
import com.ruoyi.analysiswarning.domain.vo.OverViewVo;
import com.ruoyi.analysiswarning.domain.vo.PageVO;
import com.ruoyi.analysiswarning.domain.vo.QueryVo;
import com.ruoyi.analysiswarning.service.IAnalysiswarningService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.file.FileUtils;
import com.ruoyi.formwork.domain.BaseFormWork;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.WebDataBinder;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.OutputStream;
import java.util.List;
import java.util.Map;

import static com.ruoyi.common.core.domain.AjaxResult.success;

@RestController
@RequestMapping("/analysiswarningcontroller")
public class AnalysiswarningController extends BaseController {

	@Autowired
	IAnalysiswarningService analysiswarningService;

	@InitBinder
	public void initBinder(WebDataBinder binder) {
		binder.setDisallowedFields(new String[]{"admin"});
	}

	// 查询echarts
	@Log(title = "查询echarts", businessType = BusinessType.QUERY)
	@PostMapping("/queryEcharts")
	public AjaxResult queryEcharts(@RequestBody QueryVo queryVo) {
		Map map = analysiswarningService.queryEcharts(queryVo);
		return success(map);
	}

	// 查询列表
	@PostMapping("/queryList")
	@CrossOrigin(origins = "http://localhost:8080")
	public AjaxResult queryList(@RequestBody OverViewVo overViewVo) {
		PageVO<List<AnalyOverview>> list = analysiswarningService.queryList(overViewVo);
		return success(list);
	}

	// 修改状态
	@GetMapping("updateState")
	public AjaxResult updateState(String id, String code) {
		analysiswarningService.updateState(id, code);
		return success("修改成功");
	}

}
